package com.dlc.shop.service;

import com.dlc.shop.bean.dto.StockPointSkuDTO;
import com.dlc.shop.bean.model.Sku;
import com.dlc.shop.bean.model.StockPointSku;
import com.dlc.shop.bean.vo.SkuStockVO;
import com.dlc.shop.bean.vo.StockPointSkuVO;
import com.dlc.shop.common.constants.LuaOperateEnum;

import java.util.List;
import java.util.Map;

/**
 * 库存信息
 *
 * @author LGH
 * @date 2022-05-06 14:59:42
 */
public interface SkuStockService {

    /**
     * 获取指定的sku库存列表
     * @param stockPointIdList
     * @return
     */
    List<SkuStockVO> listSkuStockBySkuIds(List<StockPointSkuVO> stockPointIdList);


    /**
     * 获取指定的sku总库存和区域库存
     * @param stockPointSkuVOList
     * @return
     */
    Map<String, SkuStockVO> mapSkuTotalStockAndPointStock(List<StockPointSkuVO> stockPointSkuVOList);


    /**
     * 获取指定的sku总库存和区域库存
     * @param skuIds
     * @return
     */
    Map<Long, SkuStockVO> mapSkuTotalStock(List<Long> skuIds);


    /**
     * 处理库存点关联数据
     * @param spuId
     * @param skuStockList
     * @param luaOperateEnum
     * @param hasUserPickUp 是否自提
     * @param shopId
     */
    void handSkuStock(Long spuId, List<SkuStockVO> skuStockList, LuaOperateEnum luaOperateEnum, Boolean hasUserPickUp, Long shopId);

    /**
     * 获取指定的sku区域库存
     * @param stockPointSkuVOList
     * @return
     */
    Map<String, SkuStockVO> mapSkuPointStockByStockPoints(List<StockPointSkuVO> stockPointSkuVOList);

    /**
     * 修改sku库存
     * @param skuStockVOList sku库存VO集合
     */
    void changeSkuStock(List<SkuStockVO> skuStockVOList);

    /**
     * 获取sku库存Map(key：skuId_stockPointId)
     * @param skuStocks sku库存数据列表
     * @return sku库存Map(key：skuId_stockPointId)
     */
    Map<String, SkuStockVO> listSkuStock(List<SkuStockVO> skuStocks);

    /**
     * 检查库存点集合是否含有该sku集合
     * @param stockPointIds 库存点id集合
     * @param skuIds skuId集合
     * @return 包含的skuId集合
     */
    List<Long> checkStockPointContainSku(List<Long> stockPointIds, List<Long> skuIds);

    /**
     * 初始化sku库存
     */
    void initStock(Integer initStock);


    /**
     * 补充库存
     * @param spuId
     * @param stockPointSkuVOList
     * @param shopId
     * @return
     */
    void addAndUpdateStockPoint(Long spuId, List<StockPointSku> stockPointSkuVOList, Long shopId);


    /**
     * 补充库存
     * @param stockPointSkuVOList
     * @return
     */
    void batchAddAndUpdateStockPoint(List<StockPointSku> stockPointSkuVOList);

    /**
     * 根据库存点id修改库存模式和库存
     * @param stockPointId
     * @param stockMode 库存模式 1 共享库存 2 独立库存
     * @param type 共享库存模式（1同步到默认仓库 2库存清零），只有切换成共享库存模式才有值
     * @param shopId
     * @param employeeId
     * @return
     */
    void updateStockMode(Long stockPointId, Integer stockMode, Integer type, Long shopId, Long employeeId);

    /**
     * 保存库存出入库数据
     * @param employeeId
     * @param mobile
     * @param sysType
     * @param stockBillType
     * @param stockType
     * @param stockPointSkuList
     * @param skus
     * @param shopId
     * @param stockPointId
     * @return
     */
    void addBillLogList(Long employeeId, String mobile, Integer sysType, int stockBillType, int stockType, List<StockPointSkuDTO> stockPointSkuList, List<Sku> skus, Long shopId, Long stockPointId);

    /**
     * 根据商品skuid和库存点获取库存点关联的商品库存
     * @param skuId
     * @param stockPointIds
     * @return
     */
    Map<Long, Integer> getStockMapBySkuIdAndStockPointIds(Long skuId, List<Long> stockPointIds);

    /**
     * 退款-还原库存
     * @param skuStockList
     */
    void orderRefundRecoveryStock(List<SkuStockVO> skuStockList);

    /**
     * 操作之前重新检查下仓库是否被删除
     * @param skuStockList
     * @return
     */
    Map<Long, Long> resetStock(List<SkuStockVO> skuStockList);

    /**
     * 恢复sku库存
     */
    void restoreStock();

    /**
     * 更新商品状态
     * @param prodIds
     * @param status
     */
    void updateSkuStockStatus(List<Long> prodIds, Integer status);
}
